using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex{
    /// <summary>
    /// Strongly-typed collection for the VCategory class.
    /// </summary>
    [Serializable]
    public partial class VCategoryCollection : ReadOnlyList<VCategory, VCategoryCollection>
    {        
        public VCategoryCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the vCategory view.
    /// </summary>
    [Serializable]
    public partial class VCategory : ReadOnlyRecord<VCategory> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vCategory", TableType.View, DataService.GetInstance("Adex"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarCategoryID = new TableSchema.TableColumn(schema);
                colvarCategoryID.ColumnName = "CategoryID";
                colvarCategoryID.DataType = DbType.Int32;
                colvarCategoryID.MaxLength = 0;
                colvarCategoryID.AutoIncrement = false;
                colvarCategoryID.IsNullable = false;
                colvarCategoryID.IsPrimaryKey = false;
                colvarCategoryID.IsForeignKey = false;
                colvarCategoryID.IsReadOnly = false;
                
                schema.Columns.Add(colvarCategoryID);
                
                TableSchema.TableColumn colvarCategoryCode = new TableSchema.TableColumn(schema);
                colvarCategoryCode.ColumnName = "CategoryCode";
                colvarCategoryCode.DataType = DbType.Int32;
                colvarCategoryCode.MaxLength = 0;
                colvarCategoryCode.AutoIncrement = false;
                colvarCategoryCode.IsNullable = false;
                colvarCategoryCode.IsPrimaryKey = false;
                colvarCategoryCode.IsForeignKey = false;
                colvarCategoryCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarCategoryCode);
                
                TableSchema.TableColumn colvarCategoryName = new TableSchema.TableColumn(schema);
                colvarCategoryName.ColumnName = "CategoryName";
                colvarCategoryName.DataType = DbType.String;
                colvarCategoryName.MaxLength = 255;
                colvarCategoryName.AutoIncrement = false;
                colvarCategoryName.IsNullable = true;
                colvarCategoryName.IsPrimaryKey = false;
                colvarCategoryName.IsForeignKey = false;
                colvarCategoryName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCategoryName);
                
                TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
                colvarDateAdded.ColumnName = "DateAdded";
                colvarDateAdded.DataType = DbType.DateTime;
                colvarDateAdded.MaxLength = 0;
                colvarDateAdded.AutoIncrement = false;
                colvarDateAdded.IsNullable = false;
                colvarDateAdded.IsPrimaryKey = false;
                colvarDateAdded.IsForeignKey = false;
                colvarDateAdded.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAdded);
                
                TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
                colvarDateModified.ColumnName = "DateModified";
                colvarDateModified.DataType = DbType.DateTime;
                colvarDateModified.MaxLength = 0;
                colvarDateModified.AutoIncrement = false;
                colvarDateModified.IsNullable = false;
                colvarDateModified.IsPrimaryKey = false;
                colvarDateModified.IsForeignKey = false;
                colvarDateModified.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateModified);
                
                TableSchema.TableColumn colvarSubSectorName = new TableSchema.TableColumn(schema);
                colvarSubSectorName.ColumnName = "SubSectorName";
                colvarSubSectorName.DataType = DbType.String;
                colvarSubSectorName.MaxLength = 500;
                colvarSubSectorName.AutoIncrement = false;
                colvarSubSectorName.IsNullable = true;
                colvarSubSectorName.IsPrimaryKey = false;
                colvarSubSectorName.IsForeignKey = false;
                colvarSubSectorName.IsReadOnly = false;
                
                schema.Columns.Add(colvarSubSectorName);
                
                TableSchema.TableColumn colvarSectorName = new TableSchema.TableColumn(schema);
                colvarSectorName.ColumnName = "SectorName";
                colvarSectorName.DataType = DbType.String;
                colvarSectorName.MaxLength = 500;
                colvarSectorName.AutoIncrement = false;
                colvarSectorName.IsNullable = true;
                colvarSectorName.IsPrimaryKey = false;
                colvarSectorName.IsForeignKey = false;
                colvarSectorName.IsReadOnly = false;
                
                schema.Columns.Add(colvarSectorName);
                
                TableSchema.TableColumn colvarTv = new TableSchema.TableColumn(schema);
                colvarTv.ColumnName = "TV";
                colvarTv.DataType = DbType.Boolean;
                colvarTv.MaxLength = 0;
                colvarTv.AutoIncrement = false;
                colvarTv.IsNullable = false;
                colvarTv.IsPrimaryKey = false;
                colvarTv.IsForeignKey = false;
                colvarTv.IsReadOnly = false;
                
                schema.Columns.Add(colvarTv);
                
                TableSchema.TableColumn colvarRd = new TableSchema.TableColumn(schema);
                colvarRd.ColumnName = "RD";
                colvarRd.DataType = DbType.Boolean;
                colvarRd.MaxLength = 0;
                colvarRd.AutoIncrement = false;
                colvarRd.IsNullable = false;
                colvarRd.IsPrimaryKey = false;
                colvarRd.IsForeignKey = false;
                colvarRd.IsReadOnly = false;
                
                schema.Columns.Add(colvarRd);
                
                TableSchema.TableColumn colvarCb = new TableSchema.TableColumn(schema);
                colvarCb.ColumnName = "CB";
                colvarCb.DataType = DbType.Boolean;
                colvarCb.MaxLength = 0;
                colvarCb.AutoIncrement = false;
                colvarCb.IsNullable = false;
                colvarCb.IsPrimaryKey = false;
                colvarCb.IsForeignKey = false;
                colvarCb.IsReadOnly = false;
                
                schema.Columns.Add(colvarCb);
                
                TableSchema.TableColumn colvarPr = new TableSchema.TableColumn(schema);
                colvarPr.ColumnName = "PR";
                colvarPr.DataType = DbType.Boolean;
                colvarPr.MaxLength = 0;
                colvarPr.AutoIncrement = false;
                colvarPr.IsNullable = false;
                colvarPr.IsPrimaryKey = false;
                colvarPr.IsForeignKey = false;
                colvarPr.IsReadOnly = false;
                
                schema.Columns.Add(colvarPr);
                
                TableSchema.TableColumn colvarOd = new TableSchema.TableColumn(schema);
                colvarOd.ColumnName = "OD";
                colvarOd.DataType = DbType.Boolean;
                colvarOd.MaxLength = 0;
                colvarOd.AutoIncrement = false;
                colvarOd.IsNullable = false;
                colvarOd.IsPrimaryKey = false;
                colvarOd.IsForeignKey = false;
                colvarOd.IsReadOnly = false;
                
                schema.Columns.Add(colvarOd);
                
                TableSchema.TableColumn colvarNs = new TableSchema.TableColumn(schema);
                colvarNs.ColumnName = "NS";
                colvarNs.DataType = DbType.Boolean;
                colvarNs.MaxLength = 0;
                colvarNs.AutoIncrement = false;
                colvarNs.IsNullable = false;
                colvarNs.IsPrimaryKey = false;
                colvarNs.IsForeignKey = false;
                colvarNs.IsReadOnly = false;
                
                schema.Columns.Add(colvarNs);
                
                TableSchema.TableColumn colvarInX = new TableSchema.TableColumn(schema);
                colvarInX.ColumnName = "IN";
                colvarInX.DataType = DbType.Boolean;
                colvarInX.MaxLength = 0;
                colvarInX.AutoIncrement = false;
                colvarInX.IsNullable = false;
                colvarInX.IsPrimaryKey = false;
                colvarInX.IsForeignKey = false;
                colvarInX.IsReadOnly = false;
                
                schema.Columns.Add(colvarInX);
                
                TableSchema.TableColumn colvarSectorID = new TableSchema.TableColumn(schema);
                colvarSectorID.ColumnName = "SectorID";
                colvarSectorID.DataType = DbType.Int32;
                colvarSectorID.MaxLength = 0;
                colvarSectorID.AutoIncrement = false;
                colvarSectorID.IsNullable = false;
                colvarSectorID.IsPrimaryKey = false;
                colvarSectorID.IsForeignKey = false;
                colvarSectorID.IsReadOnly = false;
                
                schema.Columns.Add(colvarSectorID);
                
                TableSchema.TableColumn colvarSubSectorID = new TableSchema.TableColumn(schema);
                colvarSubSectorID.ColumnName = "SubSectorID";
                colvarSubSectorID.DataType = DbType.Int32;
                colvarSubSectorID.MaxLength = 0;
                colvarSubSectorID.AutoIncrement = false;
                colvarSubSectorID.IsNullable = false;
                colvarSubSectorID.IsPrimaryKey = false;
                colvarSubSectorID.IsForeignKey = false;
                colvarSubSectorID.IsReadOnly = false;
                
                schema.Columns.Add(colvarSubSectorID);
                
                TableSchema.TableColumn colvarSectorCode = new TableSchema.TableColumn(schema);
                colvarSectorCode.ColumnName = "SectorCode";
                colvarSectorCode.DataType = DbType.Int32;
                colvarSectorCode.MaxLength = 0;
                colvarSectorCode.AutoIncrement = false;
                colvarSectorCode.IsNullable = false;
                colvarSectorCode.IsPrimaryKey = false;
                colvarSectorCode.IsForeignKey = false;
                colvarSectorCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarSectorCode);
                
                TableSchema.TableColumn colvarSubSectorCode = new TableSchema.TableColumn(schema);
                colvarSubSectorCode.ColumnName = "SubSectorCode";
                colvarSubSectorCode.DataType = DbType.Int32;
                colvarSubSectorCode.MaxLength = 0;
                colvarSubSectorCode.AutoIncrement = false;
                colvarSubSectorCode.IsNullable = false;
                colvarSubSectorCode.IsPrimaryKey = false;
                colvarSubSectorCode.IsForeignKey = false;
                colvarSubSectorCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarSubSectorCode);
                
                TableSchema.TableColumn colvarMediaType = new TableSchema.TableColumn(schema);
                colvarMediaType.ColumnName = "MediaType";
                colvarMediaType.DataType = DbType.String;
                colvarMediaType.MaxLength = 5;
                colvarMediaType.AutoIncrement = false;
                colvarMediaType.IsNullable = true;
                colvarMediaType.IsPrimaryKey = false;
                colvarMediaType.IsForeignKey = false;
                colvarMediaType.IsReadOnly = false;
                
                schema.Columns.Add(colvarMediaType);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["Adex"].AddSchema("vCategory",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public VCategory()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public VCategory(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public VCategory(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public VCategory(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("CategoryID")]
        public int CategoryID 
	    {
		    get
		    {
			    return GetColumnValue<int>("CategoryID");
		    }

            set 
		    {
			    SetColumnValue("CategoryID", value);
            }

        }

	      
        [XmlAttribute("CategoryCode")]
        public int CategoryCode 
	    {
		    get
		    {
			    return GetColumnValue<int>("CategoryCode");
		    }

            set 
		    {
			    SetColumnValue("CategoryCode", value);
            }

        }

	      
        [XmlAttribute("CategoryName")]
        public string CategoryName 
	    {
		    get
		    {
			    return GetColumnValue<string>("CategoryName");
		    }

            set 
		    {
			    SetColumnValue("CategoryName", value);
            }

        }

	      
        [XmlAttribute("DateAdded")]
        public DateTime DateAdded 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateAdded");
		    }

            set 
		    {
			    SetColumnValue("DateAdded", value);
            }

        }

	      
        [XmlAttribute("DateModified")]
        public DateTime DateModified 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateModified");
		    }

            set 
		    {
			    SetColumnValue("DateModified", value);
            }

        }

	      
        [XmlAttribute("SubSectorName")]
        public string SubSectorName 
	    {
		    get
		    {
			    return GetColumnValue<string>("SubSectorName");
		    }

            set 
		    {
			    SetColumnValue("SubSectorName", value);
            }

        }

	      
        [XmlAttribute("SectorName")]
        public string SectorName 
	    {
		    get
		    {
			    return GetColumnValue<string>("SectorName");
		    }

            set 
		    {
			    SetColumnValue("SectorName", value);
            }

        }

	      
        [XmlAttribute("Tv")]
        public bool Tv 
	    {
		    get
		    {
			    return GetColumnValue<bool>("TV");
		    }

            set 
		    {
			    SetColumnValue("TV", value);
            }

        }

	      
        [XmlAttribute("Rd")]
        public bool Rd 
	    {
		    get
		    {
			    return GetColumnValue<bool>("RD");
		    }

            set 
		    {
			    SetColumnValue("RD", value);
            }

        }

	      
        [XmlAttribute("Cb")]
        public bool Cb 
	    {
		    get
		    {
			    return GetColumnValue<bool>("CB");
		    }

            set 
		    {
			    SetColumnValue("CB", value);
            }

        }

	      
        [XmlAttribute("Pr")]
        public bool Pr 
	    {
		    get
		    {
			    return GetColumnValue<bool>("PR");
		    }

            set 
		    {
			    SetColumnValue("PR", value);
            }

        }

	      
        [XmlAttribute("Od")]
        public bool Od 
	    {
		    get
		    {
			    return GetColumnValue<bool>("OD");
		    }

            set 
		    {
			    SetColumnValue("OD", value);
            }

        }

	      
        [XmlAttribute("Ns")]
        public bool Ns 
	    {
		    get
		    {
			    return GetColumnValue<bool>("NS");
		    }

            set 
		    {
			    SetColumnValue("NS", value);
            }

        }

	      
        [XmlAttribute("InX")]
        public bool InX 
	    {
		    get
		    {
			    return GetColumnValue<bool>("IN");
		    }

            set 
		    {
			    SetColumnValue("IN", value);
            }

        }

	      
        [XmlAttribute("SectorID")]
        public int SectorID 
	    {
		    get
		    {
			    return GetColumnValue<int>("SectorID");
		    }

            set 
		    {
			    SetColumnValue("SectorID", value);
            }

        }

	      
        [XmlAttribute("SubSectorID")]
        public int SubSectorID 
	    {
		    get
		    {
			    return GetColumnValue<int>("SubSectorID");
		    }

            set 
		    {
			    SetColumnValue("SubSectorID", value);
            }

        }

	      
        [XmlAttribute("SectorCode")]
        public int SectorCode 
	    {
		    get
		    {
			    return GetColumnValue<int>("SectorCode");
		    }

            set 
		    {
			    SetColumnValue("SectorCode", value);
            }

        }

	      
        [XmlAttribute("SubSectorCode")]
        public int SubSectorCode 
	    {
		    get
		    {
			    return GetColumnValue<int>("SubSectorCode");
		    }

            set 
		    {
			    SetColumnValue("SubSectorCode", value);
            }

        }

	      
        [XmlAttribute("MediaType")]
        public string MediaType 
	    {
		    get
		    {
			    return GetColumnValue<string>("MediaType");
		    }

            set 
		    {
			    SetColumnValue("MediaType", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string CategoryID = @"CategoryID";
            
            public static string CategoryCode = @"CategoryCode";
            
            public static string CategoryName = @"CategoryName";
            
            public static string DateAdded = @"DateAdded";
            
            public static string DateModified = @"DateModified";
            
            public static string SubSectorName = @"SubSectorName";
            
            public static string SectorName = @"SectorName";
            
            public static string Tv = @"TV";
            
            public static string Rd = @"RD";
            
            public static string Cb = @"CB";
            
            public static string Pr = @"PR";
            
            public static string Od = @"OD";
            
            public static string Ns = @"NS";
            
            public static string InX = @"IN";
            
            public static string SectorID = @"SectorID";
            
            public static string SubSectorID = @"SubSectorID";
            
            public static string SectorCode = @"SectorCode";
            
            public static string SubSectorCode = @"SubSectorCode";
            
            public static string MediaType = @"MediaType";
            
	    }

	    #endregion
    }

}

